package com.lone.demo.builderpattern.cars;

import com.lone.demo.builderpattern.components.Engine;
import com.lone.demo.builderpattern.components.GPSNavigator;
import com.lone.demo.builderpattern.components.Transmission;
import com.lone.demo.builderpattern.components.TripComputer;

/**
 * @author Lone
 * @date 2021/9/22 16:14 周三
 */
public class Manual {
    private final CarType carType;
    private final Engine engine;
    private final Transmission transmission;
    private final TripComputer tripComputer;
    private final GPSNavigator gpsNavigator;
    private final int seats;

    public Manual(CarType carType, Engine engine, Transmission transmission, TripComputer tripComputer, GPSNavigator gpsNavigator, int seats) {
        this.carType = carType;
        this.engine = engine;
        this.transmission = transmission;
        this.tripComputer = tripComputer;
        this.gpsNavigator = gpsNavigator;
        this.seats = seats;
    }

    public String print() {
        String info = "";
        info += "Type of car: " + carType + "\n";
        info += "Count of seats: " + seats + "\n";
        info += "Engine: volume - " + engine.getVolume() + "; mileage - " + engine.getMileage() + "\n";
        info += "Transmission: " + transmission + "\n";
        if (this.tripComputer != null) {
            info += "Trip Computer: Functional" + "\n";
        } else {
            info += "Trip Computer: N/A" + "\n";
        }
        if (this.gpsNavigator != null) {
            info += "GPS Navigator: Functional" + "\n";
        } else {
            info += "GPS Navigator: N/A" + "\n";
        }
        return info;
    }
}
